package demo1;


class MyArray<T>{
    Object[] array=new Object[10];

    public T getArrayElement(int pos) {
        return (T)array[pos];
    }

    public void setArrayElement(int pos, T element) {
        array[pos]=element;
    }
}
public class test2 {
    public static void main(String[] args) {
        /*MyArray<String> myArray=new MyArray<>();
        myArray.setArrayElement(0,"aaa");
        myArray.setArrayElement(1,"bbb");
        myArray.setArrayElement(2,"ccc");
        System.out.println(myArray.getArrayElement(0));
        System.out.println(myArray.getArrayElement(1));
        System.out.println(myArray.getArrayElement(2));*/
        /*MyArray myArray=new MyArray();
        myArray.setArrayElement(0, "hello");
        myArray.setArrayElement(1, 100);
        String str=(String)myArray.getArrayElement(0);
        int x=(int)myArray.getArrayElement(1);
        System.out.println(str);
        System.out.println(x);*/
        MyArray myArray1=new MyArray();
        myArray1.setArrayElement(0, "hello");
        myArray1.setArrayElement(1, 100);
        String str=(String)myArray1.getArrayElement(0);
        int x=(int)myArray1.getArrayElement(1);
        System.out.println(str);
        System.out.println(x);
    }
}
